Jump to content
thirty bees forum
  • 0

Is there an easy way to add CMS page links to the navigation bar?


Question

Posted

In particular I'd like to add an "About us" link to the navigation bar in the community default theme. I thought this would be a common requirement, so I'm quite surprised no-one has apparently asked here before, unless I'm searching on the wrong terms.

I've tried to work out how to do this for myself, but it doesn't seem like it's possible from the back office as far as I can tell. Or am I missing something obvious again?

If not, any guidance would be greatly appreciated.

10 answers to this question

Recommended Posts

  • 0
Posted

I figured it out and also added a 'Home' link with the help of this old Prestashop post. The code's not exactly the same, but it was pretty straightforward to adapt – even for a non developer, like me! :)

For anyone else searching for this here, I added this code to the top of the '…/modules/blockcontact/nav.tpl' file:

```

  • {l s='Home' mod='blockcontact'}
  • {l s='About' mod='blockcontact'}
  • ``` Any experts reading this please say if I've done anything wrong or if there is a better way to accomplish this.

    • 0
    Posted

    Community theme has such a link in the footer by default.

    Assuming you mean the top menu with "navigation bar", one can add (and remove) links there on the configuration page of module Block Top Menu. Links to categories as well as links to shop CMS pages and even arbitrary links.

    • 0
    Posted

    Sorry, I assumed that would be a familiar term. I mean the bar at the very top of the site, above even the logo and search bar. Its class name is "navbar navbar-inverse" which I took to be shorthand for 'Navigation bar'. Do you call it something else?

    • 0
    Posted

    @angstony_2 You could use block top menu. It is very easy adding links there without touching any code. Modules - Block Top Menu: Add a new link:

    0_1540920156702_topmenulink.png

    • 0
    Posted

    And being a CMS page, you even should not need to create the link. Just select it from the first menu in the module and add it to the top menu bar.

    • 0
    Posted

    @cprats I tried it but found it sits on top of the central columns and underneath the logo and search bar, which is not what I wanted. Are you saying it can be used to replace the existing navbar at the very top? And if so how, please?

    • 0
    Posted

    Well I've just tried it and it does kinda work with a hook transplant to displayNav, but it's just added another row underneath the existing links. So I'd have to figure out how to remove the top row and then apply the inverse styling.

    To be honest that's already seeming like far more effort than what I've already done! But I do appreciate your suggestions. :)

    • 0
    Posted

    @angstony_2 said:

    <li id="blockcontact-about" class="blockcontact"> <a href="{$link->getCmsLink('4')|escape:'html':'UTF-8'}" title="{l s='About us' mod='blockcontact'}"> {l s='About' mod='blockcontact'} </a> </li>

    I encountered a small problem with this code yesterday. I created a new CMS page on my testing site and put a link to it in the nav bar. Once I was happy everything was working right I copied it all across to the live site. However, I'd forgotten that I'd previously added a temporary CMS page on the live site, so when I added the new CMS page there it had a different ID to the one on the testing site. This is inconvenient because it means either maintaining two different nav.tpl files, pointing to different IDs, or re-copying the live site to the testing site. So I looked in the link.php file to see if a name could be used instead of an ID, and sure enough it turns out you can use the alias (AKA 'friendly url') provided the ID parameter is passed as an empty string, so the ID becomes irrelevant.

    So this is the code I'm using now:

    <li id="blockcontact-about" class="blockcontact"> <a href="{$link->getCmsLink('', 'about-us')|escape:'html':'UTF-8'}" title="{l s='About us' mod='blockcontact'}"> {l s='About' mod='blockcontact'} </a> </li> I think this is a much better way of getting the desired CMS page link, so I thought I'd share it here.

    Create an account or sign in to comment

    You need to be a member in order to leave a comment

    Create an account

    Sign up for a new account in our community. It's easy!

    Register a new account

    Sign in

    Already have an account? Sign in here.

    Sign In Now
    ×
    ×
    • Create New...